<?php chdir($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "evolWars"); ?>
<?php require_once('includes/global_functions.php'); ?>
<?php
FunctionsFactory::getFactory()->debug("Validamos la session");
if(!isset($_SESSION['valid'])){ //Si no tenemos ningun tipo de session
	//Guardamos la URL que a picado el usuario, asi como los parametros del post y del get (request)
	if(isset($_COOKIE['EWCCC'])){
		$cookie = new cCookies(null,BDFactory::getFactory()->getBD());
		if($cookie->comprobarCookie($_COOKIE['EWCCC'])) {
			FunctionsFactory::getFactory()->redirect("home.php");
		} else {
			FunctionsFactory::getFactory()->redirect();
		}
	} else {
		FunctionsFactory::getFactory()->redirect();
	}
} else if($_SESSION['valid']==true){ //Si tenemos session, validamos que sea valida
	if (FunctionsFactory::getFactory()->ValidaSTR(strstr($_SERVER["REQUEST_URI"], "index.php"))){
		FunctionsFactory::getFactory()->redirect("home.php");
		echo $_SERVER["REQUEST_URI"]."<br />".strstr($_SERVER["REQUEST_URI"], "index.php");

	}
} else { //No tenemos nada
	FunctionsFactory::getFactory()->redirect("index.php");
}
?>